package com.huangjue.backend.dto.aiChatClient;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;
import lombok.Value;

import java.util.List;


//聊天请求
@Value
@Builder(toBuilder = true)
public class ClientRequest {
    String model;
    List<AiRequestMessage> messages;
    double temperature;
    boolean stream;


    // response_format 字段改为对象类型
    @JsonProperty("response_format")
    ResponseFormat responseFormat;

    @Value
    @Builder
    public static class ResponseFormat {
        String type; // 可以是 "text" 或 "json_object"

        public static ResponseFormat of(String type) {
            if ("text".equals(type) || "json_object".equals(type)) {
                return ResponseFormat.builder().type(type).build();
            } else {
                throw new IllegalArgumentException("Invalid type. Must be 'text' or 'json_object'.");
            }
        }
    }
    /*
     * 使用示例：
     * ClientRequest req = ClientRequest.builder()
     *     .model("kimi-k2-0711-preview")
     *     .messages(messages)
     *     .temperature(0.7)
     *     .stream(false)
     *     .responseFormat(ResponseFormat.of("json_object"))
     *     .build();
     */
}